/*
 * This file is part of quickReminder, a software for gamers
 *
 * Copyright (C) 2006-2008 Lucas Romero
 *
 * This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along with this program; if not, see <http://www.gnu.org/licenses/>.
 */
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace quickReminder
{
    public partial class FormMatchMonitor : Form
    {
        public FormMatchMonitor()
        {
            InitializeComponent();
            this.Location = new Point(Screen.PrimaryScreen.Bounds.Right - this.Width, Screen.PrimaryScreen.Bounds.Bottom - this.Height);
        }

        private void FormMatchMonitor_MouseMove(object sender, MouseEventArgs e)
        {
            Control ctrl = (Control)sender;
            label1.Text = String.Format("X: {0} Y: {1}", ctrl.PointToScreen(e.Location).X, ctrl.PointToScreen(e.Location).Y);
            label2.Text = String.Format("Moving: {0} Clicks: {1}", m_Moving, e.Clicks);
            if (m_Moving && e.Button == MouseButtons.Left)
            {
                Point p = ctrl.PointToScreen(e.Location);
                int xoff = p.X - m_LastMousePos.X;
                int yoff = p.Y - m_LastMousePos.Y;
                m_LastMousePos = p;
                p = Location;
                p.Offset(xoff, yoff);
                Location = p;
            }
        }

        private void FormMatchMonitor_Shown(object sender, EventArgs e)
        {
            
        }

        private void tsbClose_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void toolStrip1_MouseMove(object sender, MouseEventArgs e)
        {
            Control ctrl = (Control)sender;
            label1.Text = String.Format("X: {0} Y: {1}", ctrl.PointToScreen(e.Location).X, ctrl.PointToScreen(e.Location).Y);
            label2.Text = String.Format("Moving: {0} Clicks: {1}", m_Moving, e.Clicks);
            if (m_Moving && e.Button == MouseButtons.Left)
            {
                Point p = ctrl.PointToScreen(e.Location);
                int xoff = p.X - m_LastMousePos.X;
                int yoff = p.Y - m_LastMousePos.Y;
                m_LastMousePos = p;
                p = Location;
                p.Offset(xoff, yoff);
                Location = p;
            }
        }

        private void toolStrip1_MouseDown(object sender, MouseEventArgs e)
        {
            Control ctrl = (Control)sender;
            if (e.Button == MouseButtons.Left)
            {
                m_LastMousePos = ctrl.PointToScreen(e.Location);
                m_Moving = true;
            }
        }
        bool m_Moving = false;
        Point m_LastMousePos;

        private void FormMatchMonitor_MouseUp(object sender, MouseEventArgs e)
        {
            m_Moving = false;
        }

        private void FormMatchMonitor_MouseLeave(object sender, EventArgs e)
        {
            m_Moving = false;
        }
    }
}